//
//  IndicatorButton.m
//  iShow
//
//  Created by 杨 敏 on 12-11-28.
//  Copyright (c) 2012年 DreamTeam. All rights reserved.
//

#import "IndicatorButton.h"

@implementation IndicatorButton


-(void)dealloc{
    self.indicator=nil;
}

+ (IndicatorButton *)buttonWithType:(UIButtonType)buttonType{
    IndicatorButton *btn =(IndicatorButton *)[super buttonWithType:buttonType];
    return btn;
}

-(void)startIndicatorAnimating{
  //  DLog(@"");
    if (!_indicator) {
        self.indicator =[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:_isWhiteIndicator?UIActivityIndicatorViewStyleWhite:UIActivityIndicatorViewStyleGray];
        [self addSubview:_indicator];
        
    }
    _indicator.center=CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.frame)/2);
    [_indicator startAnimating];
}
-(void)layoutSubviews{
    [super layoutSubviews];
    _indicator.center=CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.frame)/2);
}
-(void)endIndicatorAnimating{
   // DLog(@"");

    [_indicator stopAnimating];
    [_indicator removeFromSuperview];
    self.indicator=nil;
}
@end
